using System.Text.Json.Serialization;
using System.Xml;
using System.Xml.Serialization;

/// <summary>
/// 通用消息内容
/// </summary>
[XmlRoot("root")]
public class MessageContentDto
{
    /// <summary>
    /// 消息类型
    /// </summary>
    [XmlElement("action")]
    public string Action { get; set; } = "sms";

    /// <summary>
    /// 手机号
    /// </summary>
    [XmlElement("sendTo")]
    public string SendTo { get; set; }

    /// <summary>
    /// 用户ID
    /// </summary>
    [XmlElement("queryId")]
    public string QueryId { get; set; }

    /// <summary>
    /// 短信内容
    /// </summary>
    [XmlElement("content")]
    public string Content { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    [XmlElement("patientName")]
    public string PatientName { get; set; }

    /// <summary>
    /// 病人ID
    /// </summary>
    [XmlElement("patientId")]
    public string PatientId { get; set; }

    /// <summary>
    /// 就诊号
    /// </summary>
    [XmlElement("visitNo")]
    public string VisitNo { get; set; }

    /// <summary>
    /// 平台信息
    /// </summary>
    [XmlIgnore]
    public MessageInfo MessageInfo { get; set; }
}

/// <summary>
/// 微信推送消息内容
/// </summary>
/// <typeparam name="T"></typeparam>
[XmlRoot("root")]
public class MessageContentDto<T> : MessageContentDto
{
    /// <summary>
    /// 推送信息
    /// </summary>
    [XmlIgnore]
    public T PushInfo { get; set; }

    /// <summary>
    /// 平台信息（xml）
    /// </summary>
    [XmlElement("message")]
    [JsonIgnore]
    public XmlNode Message
    {
        get
        {
            var node = new XmlDocument().CreateNode(XmlNodeType.CDATA, "", "");
            if (string.IsNullOrEmpty(node.InnerText))
                node.InnerText = PushInfo.ToXml2();
            return node;
        }
        set { }
    }
}

/// <summary>
/// 平台信息
/// </summary>
[XmlRoot("root")]
public class MessageInfo
{
    /// <summary>
    /// 病人电话号码
    /// </summary>
    [XmlElement("mobile")]
    public string Mobile { get; set; }

    /// <summary>
    /// 病人姓名
    /// </summary>
    [XmlElement("patientName")]
    public string PatientName { get; set; }

    /// <summary>
    /// 检查科室
    /// </summary>
    [XmlElement("deptName")]
    public string DetpName { get; set; }

    /// <summary>
    /// 检查项目
    /// </summary>
    [XmlElement("refundBalance")]
    public string RefundBalance { get; set; }

    /// <summary>
    /// 检查时间
    /// </summary>
    [XmlElement("succeedTime")]
    public string SucceedTime { get; set; }

    /// <summary>
    /// 注意事项
    /// </summary>
    [XmlElement("notes")]
    public string Notes { get; set; }

    /// <summary>
    /// 短信内容
    /// </summary>
    [XmlElement("content")]
    public string Content { get; set; }
}

/// <summary>
/// 危急值推送信息
/// </summary>
[XmlRoot("root")]
public class CriticalMessageInfo
{
    /// <summary>
    /// 病人电话号码
    /// </summary>
    [XmlElement("mobile")]
    public string Mobile { get; set; }

    /// <summary>
    /// 病人姓名
    /// </summary>
    [XmlElement("patientName")]
    public string PatientName { get; set; }

    /// <summary>
    /// 项目名称
    /// </summary>
    [XmlElement("ReportName")]
    public string ReportName { get; set; }

    /// <summary>
    /// 项目时间
    /// </summary>
    [XmlElement("ReportTime")]
    public string ReportTime { get; set; }

    /// <summary>
    /// 危急值
    /// </summary>
    [XmlElement("CriticalValue")]
    public string CriticalValue { get; set; }

    /// <summary>
    /// 提示
    /// </summary>
    [XmlElement("prompt")]
    public string Prompt { get; set; } = "";

    /// <summary>
    /// 短信内容
    /// </summary>
    [XmlElement("content")]
    public string Content { get; set; }
}

/// <summary>
/// 报告结果推送信息
/// </summary>
[XmlRoot("root")]
public class ReportMessageInfo
{
    /// <summary>
    /// 病人电话号码
    /// </summary>
    [XmlElement("mobile")]
    public string Mobile { get; set; }

    /// <summary>
    /// 病人姓名
    /// </summary>
    [XmlElement("patientName")]
    public string PatientName { get; set; }

    /// <summary>
    /// 报告类型
    /// </summary>
    [XmlElement("ReportType")]
    public string ReportType { get; set; }

    /// <summary>
    /// 项目名称
    /// </summary>
    [XmlElement("ReportName")]
    public string ReportName { get; set; }

    /// <summary>
    /// 项目时间
    /// </summary>
    [XmlElement("ReportTime")]
    public string ReportTime { get; set; }

    /// <summary>
    /// 提示
    /// </summary>
    [XmlElement("prompt")]
    public string Prompt { get; set; } = "";
}

/// <summary>
/// 设备故障信息
/// </summary>
[XmlRoot("root")]
public class DeviceFaultMessageInfo
{
    /// <summary>
    /// 病人电话号码
    /// </summary>
    [XmlElement("mobile")]
    public string Mobile { get; set; }

    /// <summary>
    /// 病人姓名
    /// </summary>
    [XmlElement("patientName")]
    public string PatientName { get; set; }

    /// <summary>
    /// 提示
    /// </summary>
    [XmlElement("prompt")]
    public string Prompt { get; set; } = "";

    /// <summary>
    /// 短信内容
    /// </summary>
    [XmlElement("content")]
    public string Content { get; set; }
}
